import dis
import inspect

frame = None
def foo():
    a= bar()
    return 1

def bar():
    global frame
    frame = inspect.currentframe()
    return 2

#查看函数字节码
dis.dis(foo)
foo()
print(frame.f_code.co_name)         # bar
print(frame.f_back.f_code.co_name)  # foo